Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
Ejecutar código después de la ejecución completa del bucle "for of"

Estoy aprendiendo "ReactJS".
Estoy usando una función para cargar varios archivos:

 const handleFileUpload = (e) => { const files = e.target.files; if (!files) return false; let formD = new FormData(); for (const file of files) { const type = file.type.split("/")[0]; // type of the file const filename = file.name; // name of the file // file reader to preview file let reader = new FileReader(); reader.onload = () => { formD.append("fileList", file, filename); setSelectedFileForUpload((prevState) => [ ...prevState, { file: reader.result, type: type, name: filename, }, ]); }; reader.readAsDataURL(file); } // for loop ---ENDS--- // Lines of code given below should only execute after for loop completed. const apiData = { documents: formD, accountId: params.accountID, }; dispatch(actions.fileUpload(apiData)); };

Así que quiero ejecutar el siguiente código después de que se complete el bucle for:

 const apiData = { documents: formD, accountId: params.accountID, }; dispatch(actions.fileUpload(apiData));
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!